﻿using System;

    class EuclideanAlgorithm
    {
        static void Main()
        {
            //Exercise 8.
            //Write a program that calculates the greatest common divisor (GCD) of given two numbers. 
            //Use the Euclidean algorithm (find it in Internet).

            Console.Write("Enter the first number:  ");
            uint firstNumber = uint.Parse(Console.ReadLine());
            Console.Write("Enter the second number:  ");
            uint secondNumber = uint.Parse(Console.ReadLine());
            

            while ((firstNumber > secondNumber) || (secondNumber > firstNumber))
            {
                while (firstNumber > secondNumber)
                {
                    firstNumber = firstNumber - secondNumber;
                }
                while (secondNumber > firstNumber)
                {
                    secondNumber = secondNumber - firstNumber;
                }                
            }
            Console.WriteLine();
            Console.WriteLine("The greatest common divisor is: {0}", firstNumber);
            Console.WriteLine();
        }
    }

